/**
 * Arduino两轮小车
 * 
 * 本程序可不受限制的用于学习和教学，商业用途请联系作者。
 * 本程序不对用户因使用程序而造成任何形式的损失负责。
 * 
 * site: http://www.xpstem.com/maker/arduino-vehicle
 * author: billy zhang
 */
 
#ifndef ARDUINO_BLUETOOTH_RECEIVER_H_
#define ARDUINO_BLUETOOTH_RECEIVER_H_

#include "RemoteReceiver.h"
#include "SerialWrapper.h"

/**
 * 蓝牙控制器类
 * 
 * 接收蓝牙连接手机端发送的数据，转换为小车控制动作。
 * 需蓝牙接收模块、手机APP配套使用。
 */
class BluetoothReceiver : public RemoteReceiver
{
   public:
     BluetoothReceiver(const SerialWrapper& bleSerial)
        :bleSerial_(bleSerial)
     {
     }

     void setup() override;
     void receive() override;

     uint8_t leftPressState() override { return leftPressState_; }
     uint8_t rightPressState() override { return rightPressState_; }
     uint8_t forwardPressState() override { return forwardPressState_; }
     uint8_t backwardPressState() override { return backwardPressState_; }
     uint8_t accelPressState() override { return accelPressState_; }
     uint8_t stopPressState() override { return stopPressState_; }
     
     int angleValue() override { return angleValue_; }
     int accelValue() override { return accelValue_; }
    
     ~BluetoothReceiver();

  private:

     const SerialWrapper& bleSerial_;
     
     uint8_t leftPressState_=0;
     uint8_t rightPressState_=0;
     uint8_t forwardPressState_=0;
     uint8_t backwardPressState_=0;
     uint8_t accelPressState_=0;
     uint8_t stopPressState_=0;

     int accelValue_=0;
     int angleValue_=0;
};

#endif
